home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.07 Jul 91 / Editor Code / editor.cp next >
Encoding:
Text File  |  1991-05-24  |  2.0 KB  |  102 lines  |  [TEXT/MPS ]

  1. #include <UMacApp.h>
  2. #include <UPrinting.h>
  3. #include <UTEView.h>
  4. #include <Fonts.h>
  5. #include <ToolUtils.h>
  6.  
  7. #include "editor.h"
  8.  
  9. const OSType kSignature     = 'JLMT';
  10. const OSType kFileType         = 'JL01';
  11. const int    kWindowID        =    1002;    
  12.  
  13. pascal TEditor::TEditor(OSType itsMainFileType)
  14. {
  15.     TWindow            *aWindow;
  16.     TEditView        *aEditView;
  17.     TTEBox            *aTEBox;
  18.     
  19.     IApplication(itsMainFileType);
  20.  
  21.     aWindow = NewTemplateWindow(kWindowID,nil);
  22.     FailNIL(aWindow);
  23.     
  24.     if (gDeadStripSuppression)
  25.     {
  26.         aEditView = new TEditView;
  27.         aTEBox = new TTEBox;
  28.     }
  29.  
  30.     aEditView = (TEditView*) aWindow->FindSubView('scrl');
  31.     FailNIL(aEditView);
  32.     aEditView->IEditView(aWindow);
  33.     
  34.     aWindow->Open();
  35. }
  36.  
  37. pascal void TEditor::HandleFinderRequest()  {};
  38.  
  39. #ifdef qDebug
  40. pascal void TEditor::IdentifySoftware()
  41. {
  42.     ProgramReport("\pEditor ©J.Langowski/MacTutor May 1991",false);
  43.     inherited::IdentifySoftware();
  44. }
  45. #endif
  46.  
  47. pascal void TEditView::IEditView(TWindow *itsWindow)
  48. {
  49.     TStdPrintHandler    *aStdPrintHandler;
  50.     
  51.     aStdPrintHandler = new TStdPrintHandler;
  52.     FailNIL(aStdPrintHandler);
  53.     aStdPrintHandler->IStdPrintHandler
  54.         (nil,this,kSquareDots,kFixedSize,!kFixedSize);
  55.     fPrintHandler = aStdPrintHandler;
  56.  
  57.     fTEView1 = (TTEView*) itsWindow->FindSubView('tx01');
  58.     FailNIL(fTEView1);
  59.     fTEView2 = (TTEView*) itsWindow->FindSubView('tx02');
  60.     FailNIL(fTEView2);
  61.     
  62.     itsWindow->SetTarget(fTEView2);
  63. }
  64.  
  65. pascal void TTEBox::Draw(Rect *area)
  66. {
  67.     Rect itsQDExtent;
  68.     
  69.     PenNormal();
  70.     GetQDExtent(&itsQDExtent);
  71.     FrameRect(&itsQDExtent);
  72.     inherited::Draw(area);
  73. }
  74.  
  75. pascal struct TCommand *TTEBox::DoMouseCommand(Point *theMouse,
  76.                     EventInfo *info, Point *hysteresis)
  77. {    
  78.     if (Focus())
  79.       {    GetWindow()->SetTarget(this); }
  80.  
  81.     return inherited::DoMouseCommand(theMouse,info,hysteresis);
  82. }
  83.  
  84.  
  85. TEditor *gEditor;
  86.  
  87. int main()
  88. {
  89.     InitToolBox();
  90.     if (ValidateConfiguration(&gConfiguration))
  91.     {
  92.         InitUMacApp(8);
  93.         InitUPrinting();
  94.         InitUTEView();
  95.         gEditor = new TEditor(kFileType);
  96.         FailNIL(gEditor);
  97.         gEditor->Run();
  98.     }
  99.     else StdAlert(phUnsupportedConfiguration);
  100.     return 0;
  101. }
  102.